import {QmsMaterialNewDefault,QmsMaterialAdd,QmsMaterialEdit} from "./Actions"
import {FetchStatus} from "../../../../configuration/RequestConfiguration"

/**
 * 获取筛选数据
 * @param state
 * @param action
 * @returns {{fetchStatus: *}}
 */
export const onQmsMaterialNewDefault = (state = {}, action) => {
  switch (action.type) {
    case QmsMaterialNewDefault: {
      switch (action.status) {
        case FetchStatus.Start: {
          return {...state, fetchStatus: action.status}
        }
        case FetchStatus.Success: {
          return {...action.json, fetchStatus: action.status}
        }
        default: {
          return {...state, fetchStatus: action.status}
        }
      }
    }
  }
  return state
};

export const onQmsMaterialAdd = (state = {}, action) => {
    switch (action.type) {
        case QmsMaterialAdd: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};

export const onQmsMaterialEdit = (state = {}, action) => {
    switch (action.type) {
        case QmsMaterialEdit: {
            switch (action.status) {
                case FetchStatus.Start: {
                    return {...state, fetchStatus: action.status}
                }
                case FetchStatus.Success: {
                    return {...action.json, fetchStatus: action.status}
                }
                default: {
                    return {...state, fetchStatus: action.status}
                }
            }
        }
    }
    return state
};


